<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/7/6
 * Time: 22:26
 */


$exception = new Exception( "why i am wrong" );

echo $exception->getLine() . PHP_EOL;
echo $exception->getCode() . PHP_EOL;
echo $exception->getFile() . PHP_EOL;
echo $exception->getMessage() . PHP_EOL;
$trace = $exception->getTrace();
var_dump( $trace );

class MyException extends Exception {

	public $previous;

	public function __construct( $message = "", $code = 0, Throwable $previous = null ) {
		$this->message = $message;
	}

	/**
	 * @param mixed $message
	 */
	public function setMessage( $message ) {
		$this->message = $message;
	}
}


$myException = new MyException();
$myException->setMessage( "wrong" );
echo $myException->getMessage();

class MySerializable implements Serializable {

	public $obj = null;

	function __construct( $obj ) {
		$this->obj = $obj;
	}

	/**
	 * String representation of object
	 * @link http://php.net/manual/en/serializable.serialize.php
	 * @return string the string representation of the object or null
	 * @since 5.1.0
	 */
	public function serialize() {
		return serialize( $this->obj );
	}

	/**
	 * Constructs the object
	 * @link http://php.net/manual/en/serializable.unserialize.php
	 *
	 * @param string $serialized <p>
	 * The string representation of the object.
	 * </p>
	 *
	 * @return void
	 * @since 5.1.0
	 */
	public function unserialize( $serialized ) {
		$this->obj = unserialize( $serialized );
	}
}

$mySerializable = new MySerializable(["fuck" => "you"]);
echo $mySerializable->serialize();
$mySerializable->unserialize( $mySerializable->serialize() );
var_dump($mySerializable->obj);